home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Online
/
TASC
/
rexx
/
TASC.thor
< prev
Wrap
Text File
|
1997-09-27
|
16KB
|
627 lines
/* $VER: TASC.thor 1.8 (08.08.97)
*
*
* Concept & Original Scripts by: Kirk Strauser <kstrauser@gxl.com>
* and Adrian Knight <ajk@dial.pipex.com>
*
* Rewritten by: Andy Macklin <badger@toadhall.u-net.com>
*/
/* Read the config file & set up defalts if it isn't there */
if open(cfg,'Env:thor/TASC.cfg',r) then do
do until eof(cfg)
lin=readln(cfg)
parse var lin id ':' V
V=strip(V)
if upper(left(id,6))='DELMSG' then
delmsg=V
if upper(left(id,3))='URG' then
urg=V
if upper(left(id,6))='MAILHD' then
mailhd=V
if upper(left(id,6))='NEWSHD' then
newshd=V
if upper(left(id,6))='GLOBPM' then
GlobPM=V
if upper(left(id,10))='POSTMASTER' then
Postmaster=V
if upper(left(id,8))='DATABASE' then
spamdb=V
if upper(left(id,8))='SRCHBODY' then
srchbody=V
if upper(left(id,6))='TRACER' then
tracer=V
if upper(left(id,8))='TRACETMP' then
tracetmp=V
if upper(left(id,7))='TRACEFI' then
tracefi=V
if upper(left(id,8))='TRACELEN' then
tracelen=V
end
call close(cfg)
end
else do
delmsg='N'
urg='N'
mailhd='Email spam'
newshd='Usenet spam/mail fraud'
globPM='N'
Postmaster=''
spamdb='spam.db'
srchbody='N'
tracer='N'
tracetmp='traceroute.tmp'
tracefi='spamtrace.db'
tracelen='3000'
end
/*=======================================================*/
/* You're not supposed to change anything from here down */
/*=======================================================*/
Parse ARG CLIARG
CLIARG=upper(CLIARG)
if CLIARG~='AUTO' & CLIARG~='' then do
say 'Template: TASC.thor [AUTO/S]'
say 'Run this script from within Thor'
exit
end
options results
options failat 31
CDB_MAIL = 1 /* Private mail conference. */
rcd=''
rl=1
thorport = address()
if left(thorport, 5) ~= 'THOR.' then do
say 'Cannot find thorport.'
exit
end
if ~show('p', 'BBSREAD') then do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
if open(A,'env:thor/thorpath') then do
THORP=READLN(A)
call close(A)
end
else do
address (thorport)
requestnotify text '"Unable to find/read env:thor/BBSdataPath"' BT '"_OK"'
exit
end
if open(T,'env:thor/BBSDataPath') then do
BBSP=READLN(T)
call close(T)
end
else do
address (thorport)
requestnotify text '"Unable to find/read env:thor/BBSdataPath"' BT '"_OK"'
exit
end
address(thorport)
CURRENTMSG stem MSG
if (rc ~= 0) then call oops("No current message.")
SAVEMESSAGE CURRENT FILE "T:tasc.tempfile"
if(rc ~= 0) then call oops("Can't save current message.")
IF Open(A,'T:tasc.tempfile','r') = 0 THEN
call oops("Couldn't open temporary file.")
i='1'
flame.=''
toaddr.=''
do until hder=''
hder= readln(A)
if upper(left(hder,8)) = 'RECEIVED' then do
Call Recd
end
if upper(left(hder,7)) = 'MESSAGE' then do
Call Mess
end
if upper(left(hder,6)) = 'RETURN' then do
Call Rtn
end
if upper(left(hder,5)) = 'REPLY' then do
Call Rply
end
if upper(left(hder,5)) = 'FROM:' then do
Call Frm
end
if upper(left(hder,5)) = 'PATH:' then do
Call Pth
end
if upper(left(hder,4)) = 'NNTP' then do
Call nntp
end
if index(hder,'ender')~=0 then do /* Sender or authenticated sender line in these headers */
Call Sndr
end
end
if upper(srchbody)='Y' then do until eof(A)
hder=readln(A)
if index(hder,'@')~=0 then do
Call Atsign
end
if index(hder,'ttp://')~=0 | index(hder,'www.')~=0 then do
Call Http
end
end
call close(A)
/* Set the values for the Mailserver */
Call Radd
/* Parse out the next level of the internet heirachy to complain to */
Call Boss
/* remove unneeded addresses (if appropriate)*/
if CLIARG~='AUTO' then do
Call Update
end
/* Check for known bad ISPs, undeliverable addresses or specific addresses for abuse. */
Call Undeliverable
address BBSREAD
READBRMESSAGE bbsname '"'MSG.BBSNAME'"' confname '"'MSG.CONFNAME'"' msgnr MSG.MSGNR headstem HEADTAGS textstem TEXTTAGS
if (rc ~= 0) then call oops
getconfdata bbsname '"'MSG.BBSNAME'"' confname '"'MSG.CONFNAME'"' stem CONFDATA
if (rc ~= 0) then call oops
UNIQUEMSGFILE bbsname '"'MSG.BBSNAME'"' stem tmp
if (rc ~= 0) then call oops
/* Build the outgoing message */
if Postmaster~='' then do
address command
'echo "From: postmaster@'||Postmaster||'" > t:tasc.tempH'
'Echo "" >> t:tasc.tempH'
end
if ~bittst(CONFDATA.FLAGS,CDB_MAIL) then do
address command 'Type "'||THORP||'rexx/SpamNewsHeader" >> T:tasc.tempH'
end
else do
address command 'Type "'||THORP||'rexx/SpamMailHeader" >> T:tasc.tempH'
end
address command 'Join t:tasc.tempH t:tasc.tempfile as 'tmp.NAME
if (rc ~= 0) then call oops("Unable to build message file.")
/* Choose the addresses from the header & the hotlist to send the complaint to */
if CLIARG~='AUTO' then do
Call Chooser
end
else do
Call AutoR
end
call WriteMessage
if (rc ~= 0) then call oops
if upper(tracer)='Y' then do
address (thorport)
do r= 1 to toaddr.count
if left(toaddr.r,1)='+' then do
toaddr.count=toaddr.count-1
end
end
Requestlist Instem toaddr outstem route dragselect multiselect title '"Send tracceroute requests for:"'
if rc=0 then do
Call Tr
end
end
if delmsg='Y' then do
address(bbsread)
UPDATEBRMESSAGE '"'MSG.BBSNAME'"' '"'MSG.CONFNAME'"' msgnr MSG.MSGNR SETDELETED
end
call tidy
Recd:
rcd.rl=hder
rl=1-rl
parse VAR hder gubbins 'from' addss 'by' remains
parse VAR addss rnme '(' brak ')'
if index(rnme,'[')~=0 then do
parse VAR rnme rnme '[' brak
end
netnum=brak
if index(brak,'(')~=0 then do
parse VAR brak xtra '(' netnum ')'
end
if index(brak,'[')~=0 then do
parse VAR brak xtra '[' netnum ']'
end
if index(brak,'@')~=0 then do
parse VAR brak gubbins '@' remains
if index(remains,'[')~=0 then do
parse VAR remains xtra '[' gubbins
end
if index(remains,'(')~=0 then do
parse VAR remains xtra '(' gubbins
end
if index(remains,' ')~=0 then do
parse VAR remains xtra ' ' gubbins
end
end
rnme=strip(rnme,'B','.]) ')
netnum=strip(netnum,'B','.]) ')
xtra=strip(xtra,'B','.]) ')
return
Mess:
/* Message ID may contain a valid _Real_ domain to complain to */
parse VAR hder gubbins '@' mnme '>'
flame.i='Msg-ID:'||strip(mnme)
i=i+1
return
Rtn:
/* Return Path might contain a valid _Real_ domain to complain to */
parse VAR hder gubbins '@' rtnme '>'
flame.i='Return Path:'||strip(rtnme)
i=i+1
return
Rply:
/* Reply-to: might contain a valid _Real_ domain to complain to */
parse VAR hder gubbins '@' rpnme ' ' remains
flame.i='Reply-To:'||strip(rpnme)
i=i+1
return
Frm:
/* From: might contain a valid _Real_ domain to complain to. I wish :( */
parse VAR hder gubbins '@' fnme '>'
flame.i='From:'||strip(fnme)
i=i+1
return
Sndr:
parse VAR hder gubbins 'sender' remains '@' sendr ' '
flame.i='Sender:'||strip(sendr,'T','.)>] ;:')
i=i+1
return
Atsign:
parse VAR hder gubbins '@' hder
parse VAR hder Atsgn ' ' gubbins
Atsgn=strip(Atsgn,T,'.>) ')
flame.i='Text(Email):'||Atsgn
i=i+1
return
Http:
if index(hder,'ttp://')~=0 then do
parse VAR hder gubbins 'ttp://' hder
end
if index(hder,'www.')~=0 then do
parse VAR hder gubbins 'www.' hder
end
parse VAR hder htp '/' gubbins
if index(htp,' ')~=0 then do
parse VAR htp htp ' ' gubbins
end
P1=lastpos('.',htp)
P2=substr(htp,P1+1)
if datatype(P2,'N')=1 then do
htp= '['||htp||']'
end
htp=strip(htp,T,' .>)')
flame.i='Text(http):'||htp
i=i+1
return
Pth:
/* Search the path: header for possible addresses (news spam only) */
P1=lastpos('!',hder)
P2=lastpos('!',hder,P1-1)
P1=substr(hder,P2+1)
parse VAR P1 parth '!' gubbins
flame.i='Path:'||strip(parth)
i=i+1
return
nntp:
/* Just in case there is an nntp-posting-host header in the news spam */
parse VAR hder gubbins ': ' nntpnme
flame.i='NNTP-Host:'||strip(nntpnme)
i=i+1
return
Radd:
if (rnme~='RNME' & rnme~='') then do
flame.i='Mailserver:'||rnme
i=i+1
end
if (netnum~='NETNUM' & netnum~='') then do
flame.i='Mailserver:['||netnum||']'
i=i+1
end
if (xtra~='XTRA' & xtra~='') then do
flame.i='Mailserver:'||xtra
i=i+1
end
return
AutoR:
j=1
toaddr.count=0
do m=1 to (i-1)
parse VAR flame.m hder ':' tnme
if bittst(confdata.flags,CDB_Mail) then do
/* A Mail message */
if hder='Msg-ID' then do
call autoadd
end
if hder='Mailserver' then do
call autoadd
end
end
else do
if hder='NNTP-Host' then do
call autoadd
end
if hder='Path' then do
call autoadd
end
end
end
if toaddr.count=0 then do
address (thorport)
requestnotify text '"No addresses suitable for autoreply option"' BT '"_OK"'
call tidy
end
else do
drop flame.
flame.count=toaddr.count
do i=1 to toaddr.count
flame.i=toaddr.i
end
end
return
autoadd:
toaddr.j='auto:'||tnme
j=j+1
toaddr.count=toaddr.count+1
return
Boss:
/* Add the option to complain further up the internet hierachy */
k=i-1
do j=1 to k
parse VAR flame.j gubbins ':' lwr '.' hghr
if left(lwr,1)~='[' then do /*Not an IP number */
if index(hghr,'.')~=0 then do
flame.i='Parent of '||gubbins||':'||hghr
i=i+1
end
end
end
return
FakeBoss:
/* Add the option to complain further up the internet hierachy, after
ignoring a faked Received: line.
*/
do j=toaddr.count to z
parse VAR toaddr.j gubbins ':' lwr '.' hghr
if left(lwr,1)~='[' then do /*Not an IP number */
if index(hghr,'.')~=0 then do
z=z+1
toaddr.z='Parent of '||gubbins||':'||hghr
end
end
end
return
Update:
m=1
toaddr.count=0
do j=1 to (i-1)
parse VAR flame.j gubbins ':' jtmp
uniq=1
do k=(j+1) to i
parse VAR flame.k gubbins ':' ktmp
if jtmp = ktmp then do
uniq=0
end
if jtmp = '' then do
uniq=0
end
end
if uniq=1 then do
toaddr.m=flame.j
toaddr.count=toaddr.count+1
m=m+1
end
end
return
Undeliverable:
if open(db,BBSP||'db/'||spamdb,r) then do
a=0
wrong.=''
correct.=''
fakehdr=''
do until eof(db)
lin=readln(db)
a=a+1
parse VAR lin wrong.a '->' correct.a
end
wrong.count=a
do m=1 to toaddr.count
parse VAR toaddr.m nme ':' oldaddr
do a=1 to wrong.count
if upper(oldaddr)=upper(wrong.a) then do
if upper(correct.a)~='UNDELIVERABLE' then do
if index(correct.a,'@')~=0 then do
toaddr.m='+'||nme||'(Redirected):'||correct.a
end
else do
if upper(correct.a)~='FAKED' then
toaddr.m=nme||'(Redirected):'||correct.a
end
if index(correct.a,'8-}')~=0 then do
toaddr.m=nme||' 8-} :'||oldaddr
end
if upper(correct.a)='FAKED' then do
if index(nme,'Mail')~=0 then do
toaddr.m='-'||nme||'*(Faked)*:'||oldaddr
if fakehdr='' then do
hder=rcd.rl
fakehdr=oldaddr
Call Recd
z=toaddr.count+1
if (rnme~='RNME' & rnme~='') then do
toaddr.z=nme||'*(Not Faked)*:'||rnme
z=z+1
end
if (xtra~='XTRA' & xtra~='') then do
toaddr.z=nme||'*(Not Faked)*:'||xtra
z=z+1
end
if (netnum~='NETNUM' & netnum~='') then do
toaddr.z=nme||'*(Not Faked)*:'||'['||netnum||']'
end
Call Fakeboss
toaddr.count=z
end
else do
warn=':'||oldaddr||' & '||fakehdr||' are faked'
toaddr.m='-'||nme||warn
end
end
else do
toaddr.m='-'||nme||'*(Faked)*'
end
end
end
else do
toaddr.m='-'||nme||':('||oldaddr||')'||correct.a
end
end
end
end
end
call close(db)
return
WriteMessage:
address BBSREAD
EVE_ENTERMSG = 0
drop EVENT.
EVENT.TONAME = ''
Do j=1 to flame.count
if globPM~='Y' then do
parse VAR flame.j tnme ':' tadd
EVENT.TONAME = EVENT.TONAME || strip(strip(tnme,B,'+'),T,'8-} ') || ','
end
else do
EVENT.TONAME = EVENT.TONAME || 'Postmaster,'
end
end
EVENT.TONAME = strip(EVENT.TONAME,T,',')
EVENT.TOADDR = ''
Do j=1 to flame.count
parse VAR flame.j tnme ':' tadd
if left(tnme,1)='+' then
EVENT.TOADDR = EVENT.TOADDR || tadd|| ','
else do
if left(tnme,1)='-' then
NOP
else
EVENT.TOADDR = EVENT.TOADDR || 'postmaster@'|| tadd ||','
end
end
EVENT.TOADDR=strip(EVENT.TOADDR,T,',')
if ~bittst(CONFDATA.FLAGS,CDB_MAIL) then do
EVENT.SUBJECT = newshd
end
else do
EVENT.SUBJECT = mailhd
end
EVENT.CONFERENCE = 'EMail'
EVENT.MSGFILE = tmp.FILEPART
if urg='Y' then do
EVENT.URGENT = 1
end
else do
EVENT.URGENT=0
end
WRITEBREVENT bbsname '"'MSG.BBSNAME'"' event EVE_ENTERMSG stem EVENT
return
Chooser:
/* Here's where the additional recipients like the IRS get added to the options */
DROP flame.
if open(A,THORP||'rexx/spamaddr','r') then do
DO WHILE ~Eof(A)
spama=readln(A)
if left(spama,1)='+' then do
i=toaddr.count+1
toaddr.i=spama
toaddr.count=toaddr.count+1
end
END
end
address(Thorport)
Requestlist Instem toaddr outstem flame dragselect multiselect title '"Complain to"'
IF (RC > 0) THEN DO
REQUESTNOTIFY TEXT '"No Addresses Selected"' BT '"_Ok"'
address command 'delete >nil: '||tmp.NAME
call tidy
EXIT
END
return
Tr:
if open(T,'env:thor/BBSDataPath') then do
BBSP=READLN(T)
call close(T)
end
else do
address (thorport)
requestnotify text '"Unable to find/read env:thor/BBSdataPath"' BT '"_OK"'
return
end
do j=1 to route.count
address command
parse VAR route.j gubbins ':' addr
'echo "echo Finding route for: '||addr||' >> '||BBSP||'db/'||tracefi||'" >> '||BBSP||'db/'||tracetmp
'echo "traceroute '||addr||' >> '||BBSP||'db/'||tracefi||'" >> '||BBSP||'db/'||tracetmp
'echo "echo Done >> '||BBSP||'db/'||tracefi||'" >> '||BBSP||'db/'||tracetmp
end
'protect '||BBSP||'db/'||tracetmp||' +s'
return
oops:
PARSE ARG errmsg
if errmsg = '' then do
if address() = "BBSREAD" then errmsg=BBSREAD.LASTERROR
else errmsg=THOR.LASTERROR
end
address(thorport)
REQUESTNOTIFY TEXT '"' errmsg '"' BT '"_Abort"'
call tidy
return
tidy:
address command 'delete >nil: T:tasc.temp#?'
exit